import 'package:demo202112/utils/common_appbar.dart';
import 'package:flutter/material.dart';

/// @Author wywinstonwy
/// @Date 2022/10/25 08:45
/// @Description:
///
///

class OpacityChangePage extends StatefulWidget {
  const OpacityChangePage({Key? key}) : super(key: key);

  @override
  State<OpacityChangePage> createState() => _OpacityChangePageState();
}

class _OpacityChangePageState extends State<OpacityChangePage> {
  double _opacity = 1.0;
  //改变目标值
  void _toggle(){
    _opacity = _opacity >0 ?0.0:1.0;
    setState(() {

    });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar("隐式动画"),
      body: Center(
        child: AnimatedOpacity(opacity: _opacity, duration: Duration(seconds: 2),
          child: Container(width: 200,height: 200,color: Colors.yellow,),
        )
      ),
      floatingActionButton: FloatingActionButton(onPressed: _toggle,child: Icon(Icons.play_arrow),),
    );
  }
}


